<?php
// +----------------------------------------------------------------------
// | Longbing [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright Chengdu longbing Technology Co., Ltd.
// +----------------------------------------------------------------------
// | Website http://longbing.org/
// +----------------------------------------------------------------------
// | Sales manager: +86-13558882532 / +86-13330887474
// | Technical support: +86-15680635005
// | After-sale service: +86-17361005938
// +----------------------------------------------------------------------

namespace app\shortvideo\model;

use app\BaseModel;
use app\shop\model\AdminGoods;

class ShortvideoGoods extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_shortvideo_goods';
    public $append = ['goods_info'];

    /**
     * @param $dis
     * @param $data
     * @return int
     * 编辑
     */
    public function goodsVideoAdd($data){
        $data['create_time'] = time();
        $data['update_time'] = time();
        $data['status']      = 1;
        $res = $this->insert($data);
        return $res;
    }

    /**
     **@param $dis
     * @功能说明:
     * @author lichuanming
     * @DataTime: 2020/5/19 10:33
     */
    public function getId($dis){
        $data = $this
            ->alias('a')
            ->leftJoin('longbing_card_goods b','a.goods_id=b.id')
            ->where($dis)
            ->column('goods_id');
        $goods_id = [];
        if(!empty($data)){
            foreach ($data as $v){
                $goods_id[] = $v;
            }
        }
        return array_values($goods_id);
    }

    /**
     * @param $where
     * @param $data
     * @return int
     * 删除
     */
    public function goodsVideoDel($where,$data){
        $res = $this->where($where)->where('id','not in',$data)->delete();
        return $res;
    }

    /**
     * @param $where
     * @return int
     * 查询
     */
    public function goodsVideoFind($where){
        $data = $this->where($where)->find();
        return $data;
    }

    /**
     * User: chenniang
     * Date: 2019-09-25 15:29
     * @return void
     * descption:转换插入数据
     */
    public function changeData($ids){
        $data = [];
        if(is_array($ids)){
            foreach ($ids as $k =>$v){
                $data[] = array_pop($v);
            }
        }
        return $data;
    }

}